import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;

import 'action.dart';
import 'state.dart';

Widget buildView(
    TextEditState state, Dispatch dispatch, ViewService viewService) {
  var border = OutlineInputBorder(
    borderSide: BorderSide(
      color: Colors.white,
    ),
  );

  return Scaffold(
    appBar: new AppBar(
        centerTitle: true,
        elevation: 2.0,
        title: new Text(
          "编辑",
          style: TextStyle(color: Colors.black54, fontSize: 18),
        )),
    body: SafeArea(
        child: Column(
      children: <Widget>[
        Expanded(
            child: SingleChildScrollView(
                child: Container(
          margin: EdgeInsets.all(10),
          child: Card(
              child: TextField(
            autofocus: true,
            maxLines: null,
            minLines: 6,
            controller: state.contentEditController,
            focusNode: state.focusNodeContent,
            decoration: InputDecoration(
              contentPadding: EdgeInsets.all(8),
              hintText: '请输入',
              enabledBorder: border,
              focusedBorder: border,
            ),
            onChanged: (input) {},
          )),
        ))),
        Container(
            padding: EdgeInsets.all(10),
            child: Row(children: <Widget>[
              Spacer(),
              FlatButton(
                textColor: Colors.white,
                padding: const EdgeInsets.all(0.0),
                child: Container(
                  decoration: const BoxDecoration(
                      gradient: LinearGradient(
                        colors: <Color>[
                          Colors.blue,
                          Colors.blue,
                        ],
                      ),
                      borderRadius: BorderRadius.all(Radius.circular(80.0))),
                  padding: const EdgeInsets.fromLTRB(30, 10, 30, 10),
                  child:
                      const Text('确定', style: TextStyle(color: Colors.white)),
                ),
                onPressed: () => dispatch(TextEditActionCreator.onSubmit()),
              ),
              Spacer(),
            ])),
      ],
    )),
  );
}
